package Shapes;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-12-16
 * Time: 13:03
 */


/**
 * Shape类是所有形状的父类
 */
public class Shape {

    public Graphics2D graphics2D;//记录画笔,用Graphics2D才能修改画笔的粗细
    public Color color;//画笔的颜色
    public  int size;//画笔的粗细

    //记录两个点的坐标,鼠标按下的坐标和释放的坐标
    //通过这两个坐标和画笔就能确定一个图形
    public int x1;
    public int x2;
    public int y1;
    public int y2;

    public Shape(int x1,int y1,int x2,int y2,Color color,int size){
        this.x1=x1;
        this.y1=y1;
        this.x2=x2;
        this.y2=y2;
        this.color=color;
        this.size=size;
    }
    public void draw(Graphics graphics){
        //设置画笔的颜色,粗细
        this.graphics2D=(Graphics2D) graphics;
        this.graphics2D.setColor(color);
        this.graphics2D.setStroke(new BasicStroke(this.size) );
    }
}
